package com.homework;

import java.util.Random;
import java.util.Scanner;

public class demo14 {
    public static void main(String[] args) {
        int[] arr = {9, 666, 188, 520, 99999};
        cJ(arr);
    }

    public static void cJ(int[] arr) {
        //随机数
        Random r = new Random();
        //循环五次，抽奖
        for (int i = 0; i < arr.length; i++) {
            //扫描器获取粉丝输入的数据
            Scanner sc = new Scanner(System.in);
            System.out.print("请按任意键完成抽奖：");
            String num = sc.next();
            System.out.println();
            for (; ; ) {
                //随机抽取数组中的索引
                int index = r.nextInt(0, 5);
                //抽奖
                int money = arr[index];
                //如果抽到重复的跳过本次
                if (money == 0) {
                    continue;
                }
                System.out.println("恭喜您抽中了：" + money);
                //被抽过的奖项赋值为0
                arr[index] = 0;
                break;
            }
        }
        System.out.println("活动结束。。。");
    }
}